import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import Login from "../views/Login";
import UpPass from "../components/wyq/UpPass";
import MyData from "../components/wyq/MyData";
import AddCase from "../components/wyq/AddCase";
import HomePage from "../components/wyq/HomePage";
import HrEmp from "../components/zxl/renshi/renshidangan/HrEmp.vue";
import HrEmpSelect from "../components/zxl/renshi/renshidangan/HrEmpSelect.vue";
import HrEmpUpdate from "../components/zxl/renshi/renshidangan/HrEmpUpdate";
import HrEmpInsert from "../components/zxl/renshi/renshidangan/HrEmpInsert";
import HrTeam from "@/components/zxl/renshi/tuanduiguanli/HrTeam";
import SystemUser from "../components/zxl/yonghu/SystemUser";
import SystemUserInsert from "../components/zxl/yonghu/SystemUserInsert";
import SystemUserSelect from "../components/zxl/yonghu/SystemUserSelect";
import SystemUserUpdate from "../components/zxl/yonghu/SystemUserUpdate";
import SystemRoleInsert from "@/components/zxl/juese/SystemRoleInsert";
import Log from "@/components/zxl/kehu/Log";
import AdmmClientUser from "@/components/zxl/kehu/AdmmClientUser";
import AdmmClientUserAll from "@/components/zxl/kehu/AdmmClientUserAll";
import InsertAdmmClientUser from "@/components/zxl/kehu/InsertAdmmClientUser";
import UpdateAdmmClientUser from "@/components/zxl/kehu/UpdateAdmmClientUser";
import InsertLogJob from "@/components/zxl/kehu/InsertLogJob";
import RecordDocument from "@/components/zxl/dangan/RecordDocument";
import RecordDocumentAll from "@/components/zxl/dangan/RecordDocumentAll";
import RecordArchiveslibrary from "@/components/zxl/dangan/RecordArchiveslibrary";
import InsertRecordArchiveslibrary from "@/components/zxl/dangan/InsertRecordArchiveslibrary";
import MyCase from "../components/wyq/MyCase";
import CaseSealApplyfor from "../components/wyq/CaseSealApplyfor";
import CaseDecrease from "../components/wyq/CaseDecrease";
import CaseAgency from "../components/wyq/CaseAgency";
import CaseTrial from "../components/wyq/CaseTrial";
import AllCase from "../components/wyq/AllCase";
import ManagerCase from "../components/wyq/ManagerCase";
import LvsKjfp from "@/components/xzh/cw/LvsKjfp";
import s12 from "@/components/xzh/cw/s12";
import LvsInout from "@/components/xzh/cw/LvsInout";
// 审批人组件
import FlowNode from "../components/cxg/FlowNode";
// 流程名称组件
import FlowName from "../components/cxg/flowname/FlowName";
// 行政-办公用品组件
import AdmArticles from "../components/cxg/admArticles/AdmArticles";
// 我的待办
import myThing from "../components/cxg/flowStart/myThing";
// 通讯录
import AdmAddresslist from "../components/cxg/admAddresslist/AdmAddresslist";
// 添加联系人
import AddAdmContacts from "../components/cxg/admAddresslist/AddAdmContacts";
//联系人详情
import QueryAdmContacts from "../components/cxg/admAddresslist/QueryAdmContacts";
// 系统日志
import SystemLog from "../components/cxg/systemLog/SystemLog";
// 文件管理
import recordFile from "../components/cxg/recordFile/recordFile";
import LvsMx from "@/components/xzh/cw/LvsMx";
// 分所
import FenSuo from "../components/cxg/fenSuo/FenSuo";
// 公告通知
import AdmNotice from "../components/cxg/admNotice/AdmNotice";
// 公告通知详情
import QueryAdmNoticeByid from "../components/cxg/admNotice/QueryAdmNoticeByid";
// 公告通知 全部
import AdmNoticesAll from "../components/cxg/admNotice/AdmNoticeAll";
// 公告添加OR修改
import UpdateAdmNotice from "../components/cxg/admNotice/UpdateAdmNotice";
// 签到管理
import AdmSigninrecor from "../components/cxg/admSigninrecor/AdmSigninrecor";
// 建议投诉
import AdmComplain from "../components/cxg/admComplain/AdmComplain";
// 通讯录详情 (人事用户详情)
import QueryAdmAddresslistByid from "../components/cxg/admAddresslist/QueryAdmAddresslistByid";
// 快速登记
import AdmExpressage from "../components/cxg/admExpressage/AdmExpressage";
// 行政 查看收件详情
import SjView from "../components/cxg/admExpressage/SjView";
// 添加收件
import addAdmExpressageSJ from "../components/cxg/admExpressage/addAdmExpressageSJ";
// 我的申请
import MyApply from "../components/cxg/flowStart/MyApply";
// 审批中心
import ApprovalCenter from "../components/cxg/flowStart/ApprovalCenter";
// 财务统计
import CwStatistics from "../components/cxg/statistics/CwStatistics";
// 执业人员财务统计
import PractitionersCwStatistics from "../components/cxg/statistics/PractitionersCwStatistics";
// 执业人员财务统计清单
import queryPractitionersCwStatistics from "../components/cxg/statistics/queryPractitionersCwStatistics";
// 收结案统计
import ShouJieCase from "../components/cxg/statistics/ShouJieCase";
// 用印统计
import Seal from "../components/cxg/statistics/Seal";
// 业务收费汇总
import chargeSummary from "../components/cxg/statistics/chargeSummary";


import LogJobquansuo from "@/components/xzh/log/LogJobquansuo";
import LogJob from "@/components/xzh/log/LogJob";
import LogJobchakan from "@/components/xzh/log/LogJobchakan";
import LogJobxiugai from "@/components/xzh/log/LogJobxiugai";
import  logjobtianjia from   "@/components/xzh/log/LogJobtianjia";
import LogJobquansuochakan from "@/components/xzh/log/LogJobquansuochakan";
import CwInvoice from "@/components/xzh/cw/CwInvoice";
import cwInout from "@/components/xzh/cw/CwInout";
import CwInvoiceGET from "@/components/xzh/cw/CwInvoiceGET";
import CwInoutSHOURU from "@/components/xzh/cw/CwInoutSHOURU";
import CwInvoiceFAPIAO from "@/components/xzh/cw/CwInvoiceFAPIAO";
import CwInoutLURU  from "@/components/xzh/cw/CwInoutLURU";
import CwInoutLURUtianjia from "@/components/xzh/cw/CwInoutLURUtianjia";
import CwInoutLURUtianjiaHOU from "@/components/xzh/cw/CwInoutLURUtianjiaHOU";
Vue.use(VueRouter)

const routes = [
  {
    path: '/home',
    name: 'Home',
    component: Home,
    children:[
            {
              path:"flownode",
              name:"flownode",
              component:FlowNode
            },
      {
        path:"flowname",
        name:"flowname",
        component:FlowName
      },
      {
        path:"mything", // 我的待办
        name:"mything",
        component:myThing
      },
      {
        path:"admaddresslist",//通讯录
        name:"admaddresslist",
        component:AdmAddresslist
      },
      {
        path:"addadmcontacts",//添加联系人
        name:"addadmcontacts",
        component:AddAdmContacts
      },
      {
        path:"queryadmcontacts",//联系人详情
        name:"queryadmcontacts",
        component:QueryAdmContacts
      },
      {
        path:"systemlog",//系统日志
        name:"systemlog",
        component:SystemLog
      },
      {
        path:"recordfile",//文件管理
        name:"recordfile",
        component:recordFile
      },
      {
        path:"fensuo",//分所管理
        name:"fensuo",
        component:FenSuo
      },
      {
        path:"admaddresslist",//通讯录
        name:"admaddresslist",
        component:AdmAddresslist
      },
      {
        path:"addadmcontacts",//添加联系人
        name:"addadmcontacts",
        component:AddAdmContacts
      },
      {
        path:"queryadmcontacts",//联系人详情
        name:"queryadmcontacts",
        component:QueryAdmContacts
      },
      {
        path:"systemlog",//系统日志
        name:"systemlog",
        component:SystemLog
      },
      {
        path:"recordfile",//文件管理
        name:"recordfile",
        component:recordFile
      },
      {
        path:"fensuo",//分所管理
        name:"fensuo",
        component:FenSuo
      },
      {
        path:"admnotice",//公告通知
        name:"admnotice",
        component:AdmNotice
      },
      {
        path:"queryadmnoticebyid",//公告通知详情
        name:"queryadmnoticebyid",
        component:QueryAdmNoticeByid
      },
      {
        path:"admnoticeall",//公告通知 全部
        name:"admnoticesall",
        component:AdmNoticesAll
      },
      {
        path:"updateadmnotice",//公告通知 修改  添加
        name:"updateadmnotice",
        component:UpdateAdmNotice
      },
      {
        path:"admsigninrecor",//签到管理
        name:"admsigninrecor",
        component:AdmSigninrecor
      },
      {
        path:"AdmComplain",//建议投诉
        name:"AdmComplain",
        component:AdmComplain
      },
      {
        path:"queryadmaddresslistbyid",// 通讯录详情
        name:"queryadmaddresslistbyid",
        component:QueryAdmAddresslistByid
      },
      {
        path:"admexpressage",// 快速登记
        name:"admexpressage",
        component:AdmExpressage
      },
      {
        path:"sjview",//收件详情
        name:"sjview",
        component:SjView
      },
      {
        path:"addadmexpressagesj",// 添加收件
        name:"addadmexpressagesj",
        component:addAdmExpressageSJ
      },
      {
        path:"myapply",// 我的申请
        name:"myapply",
        component:MyApply
      },
      {
        path:"approvalcenter",// 审批中心
        name:"approvalcenter",
        component:ApprovalCenter
      },
      {
        path:"cwstatistics",// 财务统计
        name:"cwstatistics",
        component:CwStatistics
      },
      {
        path:"practitionerscwstatistics",// 执业人员财务统计
        name:"practitionerscwstatistics",
        component:PractitionersCwStatistics
      },
      {
        path:"querypractitionerscwstatistics",// 执业人员财务统计清单
        name:"querypractitionerscwstatistics",
        component:queryPractitionersCwStatistics
      },
      {
        path:"shoujiecase",// 收结案统计
        name:"shoujiecase",
        component:ShouJieCase
      },
      {
        path:"seal", // 用印统计
        name:"seal",
        component:Seal
      },
      {
        path:"chargesummary", // 业务收费汇总
        name:"chargesummary",
        component:chargeSummary
      },
      {
        path: 'hrEmp',
        name:'HrEmp',
        component:HrEmp
      },
      {
        path: 'hrTeam',
        name:'HrTeam',
        component:HrTeam
      },
      {
        path: 'admmClientUser',
        name: 'AdmmClientUser',
        component: AdmmClientUser
      },
      {
        path: 'admmClientUserAll',
        name: 'AdmmClientUserAll',
        component: AdmmClientUserAll
      },
      {
        path: 'insertAdmmClientUser',
        name: 'InsertAdmmClientUser',
        component: InsertAdmmClientUser
      },
      {
        path: 'updateAdmmClientUser',
        name: 'UpdateAdmmClientUser',
        component: UpdateAdmmClientUser
      },
      {
        path: 'insertLogJob',
        name: 'InsertLogJob',
        component:InsertLogJob
      },
      {
        path: 'log',
        name: 'Log',
        component:Log
      },
      {
        path: 'recordDocument',
        name: 'RecordDocument',
        component:RecordDocument
      },
      {
        path: 'recordDocumentAll',
        name: 'RecordDocumentAll',
        component:RecordDocumentAll
      },
      {
        path: 'recordArchiveslibrary',
        name: 'RecordArchiveslibrary',
        component:RecordArchiveslibrary
      },
      {
        path: 'insertRecordArchiveslibrary',
        name: 'InsertRecordArchiveslibrary',
        component:InsertRecordArchiveslibrary
      },
      {
        path: 'hrEmpSelect/id',
        name:'HrEmpSelect',
        component:HrEmpSelect
      },
      {
        path: 'hrEmpUpdate/id',
        name:'HrEmpUpdate',
        component:HrEmpUpdate
      },
      {
        path: 'hrEmpInsert',
        name:'HrEmpInsert',
        component:HrEmpInsert
      },
      {
        path: 'systemUser',
        name:'SystemUser',
        component:SystemUser
      },
      {
        path: 'systemUserInsert',
        name:'SystemUserInsert',
        component:SystemUserInsert
      },
      {
        path: 'systemRoleUpdate',
        name:'SystemRoleInsert',
        component:SystemRoleInsert
      },
      {
        path: 'systemUserSelect',
        name:'SystemUserSelect',
        component:SystemUserSelect
      },
      {
        path: 'systemUserUpdate',
        name:'SystemUserUpdate',
        component:SystemUserUpdate
      },
      {
        path: 'hrEmp',
        name:'HrEmp',
        component:HrEmp
      },
      {
        path: 'hrTeam',
        name:'HrTeam',
        component:HrTeam
      },
      {
        path: 'hrEmpSelect/id',
        name:'HrEmpSelect',
        component:HrEmpSelect
      },
      {
        path: 'hrEmpUpdate/id',
        name:'HrEmpUpdate',
        component:HrEmpUpdate
      },
      {
        path: 'hrEmpInsert',
        name:'HrEmpInsert',
        component:HrEmpInsert
      },
      {
        path: 'systemUser',
        name:'SystemUser',
        component:SystemUser
      },
      {
        path: 'systemUserInsert',
        name:'SystemUserInsert',
        component:SystemUserInsert
      },
      {
        path: 'systemRoleUpdate',
        name:'SystemRoleInsert',
        component:SystemRoleInsert
      },
      {
        path: 'systemUserSelect',
        name:'SystemUserSelect',
        component:SystemUserSelect
      },
      {
        path: 'systemUserUpdate',
        name:'SystemUserUpdate',
        component:SystemUserUpdate
      },
      {
        path:"upPass",
        name:"upPass",
        component:UpPass
      },
      {
        path:"myData",
        name:"myData",
        component:MyData
      },
      {
        path:"addCase",
        name:"addCase",
        component:AddCase
      },
      {
        path:"homePage",
        name:"homePage",
        component:HomePage
      },
      {
        path:"myCase",
        name:"myCase",
        component:MyCase
      },
      {
        path:"caseSealApplyfor",
        name:"caseSealApplyfor",
        component:CaseSealApplyfor
      },
      {
        path:"caseDecrease",
        name:"caseDecrease",
        component:CaseDecrease
      },
      {
        path:"caseAgency",
        name:"caseAgency",
        component:CaseAgency
      },
      {
        path:"caseTrial",
        name:"caseTrial",
        component:CaseTrial
      },
      {
        path:"allCase",
        name:"allCase",
        component:AllCase
      },
      {
        path:"managerCase",
        name:"managerCase",
        component:ManagerCase
      },
      {
        path: "admArticles",
        name: "AdmArticles",
        component: AdmArticles
      },
      {
        path: 'logjob',
        name: 'logjob',
        component: LogJob
      },
      {
        path: 'logjobchakan',
        name: 'logjobchakan',
        component: LogJobchakan

      },

      {
        path: 'logjobxiugai',
        name: 'logjobxiugai',
        component: LogJobxiugai
      },
      {
        path: 'lvskjfp',
        name: 'lvskjfp',
        component: LvsKjfp
      },
      {
        path: 'logjobtianjia',
        name: 'logjobtianjia',
        component: logjobtianjia
      },
      {
        path: 'logjobquansuo',
        name: 'logjobquansuo',
        component: LogJobquansuo
      },
      {
        path: 'logjobquansuochakan',
        name: 'logjobquansuochakan',
        component: LogJobquansuochakan
      },
      {
        path: 'cwinout',
        name: 'cwinout',
        component: cwInout
      },
      {
        path: 'cwinvoice',
        name: 'cwinvoice',
        component: CwInvoice
      },
      {
        path: 'cwinvoiceget',
        name: 'cwinvoiceget',
        component: CwInvoiceGET
      },
      {
        path: 'lvsinout',
        name: 'lvsinout',
        component: LvsInout
      },
      {
        path: 'cwinoutshouru',
        name: 'cwinoutshouru',
        component: CwInoutSHOURU
      },
      {
        path: 'cwinvoicefapiao',
        name: 'cwinvoicefapiao',
        component: CwInvoiceFAPIAO
      },
      {
        path: 'cwinoutluru',
        name: 'cwinoutluru',
        component: CwInoutLURU
      },
      {
        path: 'cwinoutlurutianjia',
        name: 'cwinoutlurutianjia',
        component: CwInoutLURUtianjia
      }
      ,
      {
        path: 'cwinoutlurutianjiahou',
        name: 'cwinoutlurutianjiahou',
        component: CwInoutLURUtianjiaHOU
      },
      {
        path: 'zhifu',
        name: 'zhifu',
        component: s12
      }
      ,
      {
        path: 'lvsmx',
        name: 'lvsmx',
        component: LvsMx
      }
    ]
  },
  {
    path: '/',
    name: 'Login',
    component: Login
  },
  {
    path: '/about',
    name: 'About',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  },
];

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
});


// 解决ElementUI导航栏中的vue-router在3.0版本以上重复点菜单报错问题
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
};

//定义全局导航守卫，每次路由前都要检查是否登录，如果登录过放行，否则跳转登录页面
router.beforeEach((to, from, next) => {
  //获取token
  let token = localStorage.getItem("token")||"";
  if(token==="" && to.path !=="/"){//跳转登录
    next("/")//跳登录页面
  }else{//放行
    next();
  }
});

export default router
